/*
 * Copyright (c) zhg2yqq.com Corp.
 * All Rights Reserved.
 */
package com.zhg2yqq.wheels.job.constant;

import java.util.Arrays;

/**
 * @author zhg2yqq, 2023年2月17日
 * @version zhg2yqq v1.0
 */
public class JobConstant {
    public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";

    /**
     * 执行目标key
     */
    public static final String TASK_PROPERTIES = "TASK_PROPERTIES";

    /**
     * 默认
     */
    public static final String MISFIRE_DEFAULT = "0";

    /**
     * 立即触发执行
     */
    public static final String MISFIRE_IGNORE_MISFIRES = "1";

    /**
     * 触发一次执行
     */
    public static final String MISFIRE_FIRE_AND_PROCEED = "2";

    /**
     * 不触发立即执行
     */
    public static final String MISFIRE_DO_NOTHING = "3";

    public enum Status {
        /**
         * 正常
         */
        NORMAL("NORMAL"),
        /**
         * 暂停
         */
        PAUSE("PAUSE");

        private String value;

        private Status(String value) {
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public static Status getStatus(String status) {
            return Arrays.stream(values()).filter(s -> s.getValue().equals(status)).findFirst()
                    .orElse(null);
        }
    }
}
